package com.ruoyi.aqi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aqi.domain.PrsaData;
import com.ruoyi.aqi.service.IPrsaDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * PRSA原始数据Controller
 * 
 * @author houtaroy
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/aqi/prsa")
public class PrsaDataController extends BaseController
{
    @Autowired
    private IPrsaDataService prsaDataService;

    /**
     * 查询PRSA原始数据列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrsaData prsaData)
    {
        startPage();
        List<PrsaData> list = prsaDataService.selectPrsaDataList(prsaData);
        return getDataTable(list);
    }

    /**
     * 导出PRSA原始数据列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:export')")
    @Log(title = "PRSA原始数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrsaData prsaData)
    {
        List<PrsaData> list = prsaDataService.selectPrsaDataList(prsaData);
        ExcelUtil<PrsaData> util = new ExcelUtil<PrsaData>(PrsaData.class);
        util.exportExcel(response, list, "PRSA原始数据数据");
    }

    /**
     * 获取PRSA原始数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(prsaDataService.selectPrsaDataById(id));
    }

    /**
     * 新增PRSA原始数据
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:add')")
    @Log(title = "PRSA原始数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrsaData prsaData)
    {
        return toAjax(prsaDataService.insertPrsaData(prsaData));
    }

    /**
     * 修改PRSA原始数据
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:edit')")
    @Log(title = "PRSA原始数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrsaData prsaData)
    {
        return toAjax(prsaDataService.updatePrsaData(prsaData));
    }

    /**
     * 删除PRSA原始数据
     */
    @PreAuthorize("@ss.hasPermi('aqi:prsa:remove')")
    @Log(title = "PRSA原始数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(prsaDataService.deletePrsaDataByIds(ids));
    }
}
